package sistema.validador;

// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 29/3/2006 21:06:19
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   DiffIgnoreFileHeaderWhitespace.java

import java.io.*;

class DiffIgnoreFileHeaderWhitespace extends ValidatorSpace
{

    public void close()
        throws IOException
    {
        pr.close();
    }

    public String diff_iniwhiteSp11(PushbackReader pr)
        throws IOException
    {
        StringBuffer sb;
label0:
        {
            boolean type = true;
            sb = new StringBuffer();
            int c;
            char ch;
            do
            {
                c = pr.read();
                if(c == -1)
                    return null;
                ch = (char)c;
                if(flag)
                {
                    if(c >= 32 && c <= 126 || c == 9 || c == 10 || c == 13)
                        type = false;
                } else
                if(c > 32 && c <= 126)
                    type = false;
            } while(type);
            foundcr = false;
            if(flag || ch != ' ')
            {
                sb.append(ch);
                if(c == 13)
                {
                    sb.append("\n");
                    foundcr = true;
                } else
                if(c == 10 && !foundcr)
                {
                    sb.append("\n");
                    foundcr = false;
                }
            }
            do
            {
                c = pr.read();
                if(c == -1)
                    break label0;
                ch = (char)c;
                if(c >= 33 && c <= 126 || c == 9)
                {
                    sb.append(ch);
                    flag = true;
                    continue;
                }
                if(flag && c == 32)
                {
                    sb.append(ch);
                    continue;
                }
                if(c != 10 && c != 13 || !flag)
                    break;
                if(c == 13)
                {
                    sb.append("\n");
                    foundcr = true;
                } else
                if(c == 10 && !foundcr)
                {
                    sb.append("\n");
                    foundcr = false;
                }
            } while(true);
            pr.unread(c);
        }
        return sb.toString();
    }

    public void diffIniWhiteSp(FileReader fr, String temp1, PrintWriter log)
        throws IOException
    {
        BufferedReader br = new BufferedReader(fr);
        pr = new PushbackReader(br, 1);
        try
        {
            PrintWriter pw = new PrintWriter(new FileOutputStream(temp1), true);
            log.println("-------------------------***START EXCUTING VALIDATORINITIAL SPACE***-----------------------");
            log.println("-------------------------***WRITING IN TEMP FILE (" + temp1 + ") ***-----------------------");
            flag = false;
            StringBuffer sb1 = new StringBuffer();
            String token;
            while((token = diff_iniwhiteSp11(pr)) != null) 
                if(token.length() > 1)
                    sb1.append(token);
            pw.println(sb1);
            log.println(sb1);
        }
        catch(IOException e)
        {
            System.out.println("FAILED TO WRITE IN THE TEMP FILE (" + temp1 + ")" + e.toString());
            log.println("FAILED TO WRITE IN THE TEMP FILE (" + temp1 + ")" + e.toString());
        }
        log.println("-------------------------***END EXECUTING VALIDATORINITIAL SPACE***-----------------------");
    }

    public DiffIgnoreFileHeaderWhitespace()
    {
        flag = false;
        foundcr = false;
        countcarriage = -1;
        flag = false;
    }

    private PushbackReader pr;
    public boolean flag;
    public boolean foundcr;
    public int countcarriage;
}